package graph_viewer.structure;

import java.awt.Graphics;
import java.util.*;

import graph_viewer.canvas.*;
import graph_viewer.util.*;

public class Abridgement_Node extends Node{
	private String
				the_label,
				the_parent_label;
	
	private ArrayList the_children_labels;
	private boolean is_closed;
	private Node_Position	the_position;

	public Abridgement_Node(){}

	public Abridgement_Node( Node a_node ){
		Debug.println( "Start to craete Abridgement_Node node from " + a_node, 40 );

		set_label( a_node.get_label() );
		set_children_labels( a_node.find_children_labels() );
		set_is_closed( a_node.get_is_closed() );
		set_position( a_node.get_position() );
		
		if ( a_node.is_root() ){
			the_parent_label = null;
		}else{
			set_parent_label( a_node.get_parent().get_label() );
		}

		Debug.println( "Finish to craete Abridgement_Node node from " + a_node, 40 );

	}
	
	public String toString(){
		StringBuffer	an_abridgment_node	= new StringBuffer();

		an_abridgment_node.append( "\n[" );
		an_abridgment_node.append( the_label + ", has parent: " + the_parent_label + ", has children " + the_children_labels );
		an_abridgment_node.append( "at: " + the_position );
		an_abridgment_node.append( ", is_closed? " + is_closed );
		an_abridgment_node.append( "]\n" );

		return an_abridgment_node.toString();
	}
	
	//============================================================================
	// setter and getter
	//============================================================================
	public void set_label( String a_label ){
		this.the_label	= a_label;
	}

	public String get_label(){
		return the_label;
	}

	public void set_parent_label( String a_parent_label ){
		the_parent_label	= a_parent_label;
	}

	public String get_parent_label(){
		return the_parent_label;
	}

	public void set_children_labels( ArrayList a_children_labels ){
		the_children_labels	 = new ArrayList( a_children_labels );
	}

	public ArrayList get_children_labels(){
		return the_children_labels;
	}

	public boolean get_is_closed(){
		return is_closed;
	}

	public void set_is_closed( boolean status ){
		is_closed	 = status;		
	}

	public void set_position( Node_Position	 a_np ){
		the_position	= new Node_Position( a_np );
	}

	public Node_Position get_position(){
		return the_position;
	}
};
